﻿namespace EveKillboard.Core.Interfaces
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq.Expressions;
    using System.Linq;

    public interface IDataAccessProvider : IDisposable
    {
        void Initialize();
        bool Exists<T>(Expression<Func<T, bool>> predicate, out T value) where T : class;
        void Delete<T>(Expression<Func<T, bool>> predicate) where T : class;
        int? GetId<T>(Expression<Func<T, bool>> predicate) where T : class, IId;
        T Add<T>(T value) where T : class;
        T Save<T>(T value) where T : class;
        T Find<T>(int id) where T : class, IId;
        T Find<T>(Expression<Func<T, bool>> predicate) where T : class;
        IQueryable<T> Query<T>() where T : class;
        IQueryable<T> FindAll<T>(Expression<Func<T, bool>> predicate, bool track = true) where T : class;
        IEnumerable<T> FindAll<T>(bool track = true) where T : class;
        IEnumerable<T> FindAll<T>(int maxcount = 0, int skip = 0, bool track = true) where T : class;
        IEnumerable<T> FindAll<T>(Expression<Func<T, bool>> predicate, int maxcount = 0,int skip = 0, bool track = true) where T : class;
        IEnumerable<TResult> Select<T, TResult>(Expression<Func<T, bool>> predicate, Expression<Func<T, TResult>> selector, bool track = true) where T : class;
        int? Sum<T>(Expression<Func<T, bool>> predicate, Expression<Func<T, int?>> selector) where T : class;
        decimal? Sum<T>(Expression<Func<T, bool>> predicate, Expression<Func<T, decimal?>> selector) where T : class;
        int SqlQuery(string command, object[] parameters);
        IEnumerable<T> SqlQuery<T>(string sql, object[] parameters);
        IEnumerable SqlQuery(Type elementType, string sql, object[] parameters);
    }
}